package main

import (
	"fmt"
	"strings"
)

func main() {

	var userMap map[string]string
	userMap = make(map[string]string)
	// userMap := make(map[string]string)

	for i := 0; i < 5; i++ {
		key := fmt.Sprintf("%s%d", "key", i)
		value := fmt.Sprintf("%s%d", "value", i)
		userMap[key] = value
	}
	PrintMap(userMap)
	fmt.Println(">>>>> point ptr change value >>>>>")
	changeMap(&userMap)
	PrintMap(userMap)

	fmt.Println(">>>>>local method change >>>>>>")
	changeMapLocal(userMap)
	PrintMap(userMap)
}

func PrintMap(tempMap map[string]string) {
	for key := range tempMap {
		fmt.Println("key >> " + key + " value >> " + tempMap[key])
	}
}

func changeMap(tempMap *map[string]string) {
	for key := range *(tempMap) {
		if strings.EqualFold("key0", key) {
			(*tempMap)[key] = "changed Value"
		}
	}
}

func changeMapLocal(tempMap map[string]string) {
	for key := range tempMap {
		if strings.EqualFold("key0", key) {
			tempMap[key] = "changed Value local"
			fmt.Println(">>>>>key0 changed value >>>>")
		}
	}
}
